home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / HARDWARE.SWG / 0037_Math Co-Processor Speed.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-26  |  1KB  |  75 lines

  1. {
  2. Here is a program I wrote to see how good my new 387sx co-processor was. It
  3. uses the standard REAL type.
  4. }
  5. program Math_Speed_Test;
  6. {$N-,E-,R-,S-}
  7.  
  8. uses dos;
  9.  
  10. var i : longint;
  11.     num1, num2, num3 : real; { or double }
  12.     output : text;
  13.     hou,minu,seco,s100 : word;
  14.     StartClock,
  15.     StopClock : Real;
  16.  
  17. Procedure ClockOn;
  18.  
  19. Begin
  20.      GetTime(hou,minu,seco,s100);
  21.      StartClock:=( hou * 3600 ) + ( minu * 60 ) + seco + ( s100 / 100 );
  22. End;
  23.  
  24. Procedure ClockOff;
  25.  
  26.  
  27. Begin
  28.      GetTime(hou,minu,seco,s100);
  29.      StopClock:=( hou * 3600 ) + ( minu * 60 ) + seco + ( s100 / 100 );
  30.      WriteLn(output,'Elapsed Time = ',(StopClock-StartClock):0:2,'s');
  31. End;
  32.  
  33.  
  34. begin
  35.      assign(output,'');
  36.      rewrite(output);
  37.      clockon;
  38. {$IFOPT N+}
  39.      writeln(output,'Using 8087 Code');
  40. {$ELSE}
  41.      writeln(output,'Using Software floating point routines');
  42. {$ENDIF}
  43.      for i:=1 to 100000 do
  44.      begin
  45.  
  46.      num1:=random(60000)/100;
  47.      repeat
  48.      num2:=random(60000)/100;
  49.      until num2>0;
  50.      num3:=num1/num2;
  51.  
  52.      end;
  53.      clockoff;
  54.      close(output);
  55.  
  56. end.
  57.  
  58. And the results.....
  59.  
  60. Using Software floating point routines
  61. Elapsed Time = 31.03s
  62.  
  63. Using 8087 Code
  64. Elapsed Time = 8.78s
  65.  
  66. However, changing REAL to DOUBLE gives
  67.  
  68. Using 8087 Code
  69. Elapsed Time = 5.50s
  70.  
  71. I don't want to remove my co-processor, so I can't get the results for
  72. using the emulation library :-). You could compile the program and try it
  73. for yourself.
  74.  
  75.